package edu.egypt.optionsmenu;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

//objective 1 : construct an options menu dynamically (using the code)
public class OptionsMenuSampleActivity extends Activity {
    
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
    }
    
    public void createMenu(Menu menu){
    	MenuItem mItem1 = menu.add("Camera");
    	mItem1.setIcon(android.R.drawable.ic_menu_camera);
    	MenuItem mItem2 = menu.add("Add");
    	mItem2.setIcon(android.R.drawable.ic_menu_add);
    	MenuItem mItem3 = menu.add("Compass");
    	mItem3.setIcon(android.R.drawable.ic_menu_compass);
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		createMenu(menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		Toast.makeText(getBaseContext(), "You Selected: "+item.getTitle(), Toast.LENGTH_SHORT).show();
		return true;
	}
	
	
	
	
    
    
    
}